package com.hk.service;

import java.util.ArrayList;

import com.hk.dtos.BBSDto;
import com.hk.dtos.PhotoDto;
import com.hk.dtos.SearchDto;
import com.hk.ibatis.SqlDaoSuport;
import com.hk.idtos.IPhotoDto;

public class PhotoManager extends SqlDaoSuport implements IPhotoDto{

public ArrayList<PhotoDto> getPhotoList() {
	 	
		ArrayList<PhotoDto> i = null;
	 	try {
			i = (ArrayList<PhotoDto>)this.getSqlMapClient().queryForList("photolist");
		} catch (Exception e) {
			System.out.println(e);
			
	 	}
		return i;
	 
	 }	
	public PhotoDto getPhoto(int seq) {
	 	
		PhotoDto photo = new PhotoDto();
	 	try {
			photo = (PhotoDto)this.getSqlMapClient().queryForObject("getPhoto",seq);
		} catch (Exception e) {
			System.out.println(e);
			
	 	}
		return photo;
	 
	 }
	public void insPhoto(PhotoDto dto) {
	 	
	 	
	 	try {
		 this.getSqlMapClient().insert("photoadd",dto);
		} catch (Exception e) {
			System.out.println(e);
			
	 	}
		
	 
	 }
	
	public ArrayList<PhotoDto> maxSeq() {
		
		ArrayList<PhotoDto> temp=null;
	 	try {
			temp = (ArrayList<PhotoDto>)this.getSqlMapClient().queryForList("pmaxSeq");
		} catch (Exception e) {
			System.out.println(e);
			
	 	}
		return temp;
	}
	public boolean del(int seq){
			int answer=1;
								
			try {
				this.getSqlMapClient().update("pdel",seq);
			} catch (Exception e) {
				System.out.println(e);
				answer=-1;
			}
			return answer>0?true:false;
		}
		
		public boolean updel(PhotoDto dto){
			int answer=1;
								
			try {
				this.getSqlMapClient().update("pupdel",dto);
			} catch (Exception e) {
				System.out.println(e);
				answer=-1;
			}
			return answer>0?true:false;
		}
		public boolean modUpdateBoard(PhotoDto dto){
 			int answer=1;
 			
 			try {
 				this.getSqlMapClient().update("pmodUpdateBoard",dto);
 			} catch (Exception e) {
 				System.out.println(e);
 				answer=-1;
 			}
 			return answer>0?true:false;
 		}
		public String getDate(){
 			
 			String date=null;					
 			try {
 				date=(String)this.getSqlMapClient().queryForObject("getDate");
 			} catch (Exception e) {
 				System.out.println(e);
 				
 			}
 			return date;
 		}
		public int pcountbbs(){
			int result = 0;
			try {
				result=(Integer)getSqlMapClient().queryForObject("pcountbbs");
			} catch (Exception e) {
				System.out.println(e);
			}		 
			return result;
		}// getAnswerBoards

		public ArrayList<PhotoDto> seidbbs(SearchDto sdto) {
			ArrayList<PhotoDto> result=null;
			try {
				result=
			 (ArrayList<PhotoDto>)getSqlMapClient().queryForList("pseid",sdto);
			} catch (Exception e) {
				System.out.println(e);
			}		 
			return result;
		}// getAnswerBoards

		@Override
		public ArrayList<PhotoDto> setitlebbs(SearchDto sdto) {
			ArrayList<PhotoDto> result=null;
			
			try {
				result=
			 (ArrayList<PhotoDto>)getSqlMapClient().queryForList("psetitle",sdto);
			} catch (Exception e) {
				System.out.println(e);
			}		 
			return result;
		}
		@Override
		public ArrayList<PhotoDto> pagebbs(SearchDto sdto) {
			ArrayList<PhotoDto> result=null;
			try {
				result=
			 (ArrayList<PhotoDto>)getSqlMapClient().queryForList("pbbslist",sdto);
			} catch (Exception e) {
				System.out.println(e);
			}		 
			return result;
		}
	
}
